<template>
	<view>
		<view class="avatar-wrapper">
			<image :src="user.avatarPath" mode="aspectFill" class="avatar"/>
		</view>
		<view class="u-wrapper">
			<text class="text">{{ user.showName }}</text>
		</view>

        <uni-list class="btn-wrapper-list">
        	<uni-list-item title="账号&安全" showArrow link="redirectTo" to="./chat" @click="onClick" />
        	<uni-list-item title="帮助文档" showArrow link="redirectTo" to="./chats" @click="onClick" />
			<uni-list-item title="服务中心" showArrow link="redirectTo" to="./chats" @click="onClick" />
			<uni-list-item title="我的收藏" showArrow link="redirectTo" to="./chats" @click="onClick" />
			<uni-list-item title="环境切换" showArrow link="navigateTo" to="/pages/setting/env" />
        </uni-list>
		
		<view class="btn-wrapper">
			<button type="warn" @click="logout">退出登录</button>
		</view>
	</view>
</template>

<script>
	import * as Constant from "../../utils/constant";
	import * as userService from "../../services/UserService";
	import * as env from '../../env';
	import {setAuthorization,removeAuthorization,getAuthorization} from '@/utils/auth';
	export default {
		data() {
			return {
				user:{

				}
			}
		},
		onLoad() {
			this.loadUserBasicInfo();
		},
		methods: {
			logout(){
				console.log("####exit,");
				removeAuthorization();
				uni.navigateTo({
					url:"/pages/account/login"
				})
			},
			loadUserBasicInfo(){
				userService.queryUserBasicInfo().then(res=>{
					console.log('###user,',res);
					if(res.code==Constant.SUCCESS){
						this.user=res.data;
					}
				}).catch(err=>{

				})
			}
		}
	}
</script>

<style lang="scss">
	.avatar-wrapper{
		text-align: center;
		.avatar{
			width:100px;
			height:100px;
		}
	}

	.u-wrapper{
		text-align: center;
	}
	
	.btn-wrapper{
		padding:10px;
	}
	
	.btn-wrapper-list{
		margin-top: 10px;
	}
	
</style>
